package cool.qingqing.lambda;

import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 高山青
 * @Date 2022/1/4  -   10:50
 */
public class FunctionTest {
	public static void main(String[] args) throws NoSuchMethodException {

		Integer[] integers=map(integers1 -> {
			Integer[] result=new Integer[integers1.length];
			for (int i = 0; i < integers1.length; i++) {
				result[i]=integers1[i]*integers1[i];
			}
			return result;
		});
		String returnTypeName=FunctionTest.class.getDeclaredMethod("map",Function.class).getReturnType().getName();
		String ra=returnTypeName.substring(returnTypeName.lastIndexOf(".")+1,returnTypeName.length()-1);
		System.out.println(ra);

			System.out.println(FunctionTest.class.getDeclaredMethod("map",Function.class).getName()+"=>"+
					Arrays.stream(FunctionTest.class.getDeclaredMethod("map",Function.class)
							.getParameterTypes()).map(m->{
								return m.getTypeName();
					}).collect(Collectors.joining())+"->"+ra+"  "

					+Arrays.toString(integers));

	}

	public static Integer[] map(Function<Integer[],Integer[]> function){

		Integer[] integers={1,4,6,8,35,56};
		return function.apply(integers);

	}
}
